Skip to content

Conversation

@dcpena
Copy link
Collaborator

@dcpena dcpena commented Oct 2, 2024

Fixed an incorrect code example and added a new page for uploading an image with a worker to address PCX-13703.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 2, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0d21e26
Status: ✅  Deploy successful!
Preview URL: https://35efd827.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://dpena-images-13703.cloudflare-docs-7ou.pages.dev

View logs

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2024

@dochne
Copy link
Contributor

dochne commented Oct 3, 2024

I think it's worth us adding an example here phrased as "Uploading from AI Generated Images" with this code in it:

const API_URL = "https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1";
const TOKEN = "YOUR_TOKEN_HERE";

const stream = await env.AI.run(
  "@cf/bytedance/stable-diffusion-xl-lightning",
  {
    prompt: YOUR_PROMPT_HERE
  }
);
const bytes = await (new Response(stream)).bytes();

const formData = new FormData();
formData.append('file', new File([bytes], 'image.jpg');

const response = await fetch(API_URL, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${TOKEN}`,
  },
  body: formData,
});

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 files reviewed, 1 total issue(s) found.

dcpena and others added 3 commits October 4, 2024 10:14
@dcpena dcpena merged commit 88cb15e into production Oct 9, 2024
13 checks passed
@dcpena dcpena deleted the dpena/images-13703 branch October 9, 2024 21:18
elithrar pushed a commit that referenced this pull request Oct 15, 2024
* Corrected example

* Added upload an image using a Worker

* Implementing feedback

* Added more background info to AI image task

* Added more info for uploading AI generated image

* Update src/content/docs/images/upload-images/upload-file-worker.mdx

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Header edit

---------

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
maheshwarip pushed a commit that referenced this pull request Dec 2, 2024
* Corrected example

* Added upload an image using a Worker

* Implementing feedback

* Added more background info to AI image task

* Added more info for uploading AI generated image

* Update src/content/docs/images/upload-images/upload-file-worker.mdx

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Header edit

---------

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:images Related to Image Resizing product size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.